use redis::{Client, Commands, FromRedisValue, RedisResult, ToRedisArgs};
use crate::core::CTX;

#[allow(dead_code)]
pub fn set_ex<K:ToRedisArgs, V:ToRedisArgs>(key:K, value:V, second:u64) -> RedisResult<()> {
    let _:() = Client::set_ex(&mut CTX.rd.clone(), key, value, second)?;
    Ok(())
}

#[allow(dead_code)]
pub fn get<T:FromRedisValue,K:ToRedisArgs>(key:K)->RedisResult<T>{
    let t:T = Client::get(&mut CTX.rd.clone(),key)?;
    Ok(t)
}

#[allow(dead_code)]
#[allow(unused_must_use)]
pub fn del<K:ToRedisArgs>(key:K)->RedisResult<()>{
    let _:() = Client::del(&mut CTX.rd.clone(),key)?;
    Ok(())
}